package com.sxm.yiwei.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.sxm.yiwei.R;
import com.sxm.yiwei.utils.InternetAddressUtis;

import org.xutils.x;

import java.util.HashMap;
import java.util.List;


/**
 * Created by KuKa on 2017/7/15.
 * 图片列表
 */

public class FwDiscussGridAdapter extends BaseAdapter {
    Context context;
    List<?> map;
    public FwDiscussGridAdapter(Context context, List<?>  map) {
        this.context = context;
        this.map = map;
    }

    @Override
    public int getCount() {
        return map.size()==0?0:map.size();
    }

    @Override
    public Object getItem(int position) {
        return map.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView==null){
            view = View.inflate(context, R.layout.discuss_grid_item,null);
            holder = new ViewHolder();
            holder.gridimg = (ImageView) view.findViewById(R.id.dis_grid_img);
            view.setTag(holder);
        }else {
            view= convertView;
            holder = (ViewHolder) view.getTag();
        }
        x.image().bind(holder.gridimg, InternetAddressUtis.IMG_URL+map.get(position));
        notifyDataSetChanged();
        return view;
    }
    class ViewHolder{
        ImageView gridimg;
    }
}
